package com.situ.day7.homework;

import static org.hamcrest.CoreMatchers.describedAs;

import java.awt.image.BandCombineOp;
import java.util.Scanner;

public class AccountAdmin {
	//属性：账号（account）、储户姓名(name)、地址(address)、存款余额(balance)、最小余额(minBalance)
	//账号
	private String account;
	//储户姓名
	private String name;
	//地址
	private String address;
	//存款余额
	private double balance;
	//最小余额
	private double minBalance;
	
	public AccountAdmin() {
		super();
	}

	public AccountAdmin(String account, String name, String address, double balance, double minBalance) {
		super();
		this.account = account;
		this.name = name;
		this.address = address;
		this.balance = balance;
		this.minBalance = minBalance;
	}
	
	//主程序调用这个方法，启动账户管理的程序
	public void work() {
		while (true) {
			System.out.println("您好，请选择相应的操作");
			System.out.println("1、查询");
			System.out.println("2、存款");
			System.out.println("3、取款");
			System.out.println("4、退卡");
			Scanner scanner = new Scanner(System.in);
			int type = scanner.nextInt();
			if (type == 4) {
				System.out.println("退卡");
				return;
			}
			
			switch (type) {
			case 1://查询
				System.out.println("账户余额：" + balance);
				break;
			case 2:
				cunKuan();
				break;
			case 3:
				quKuan();
				break;
			default:
				break;
			}
		}
	}

	/**
	 * 取款
	 */
	private void quKuan() {
		System.out.println("请输入取款金额");
		Scanner scanner = new Scanner(System.in);
		double output = scanner.nextDouble();
		if (balance - output >= minBalance) {//可以取款
			System.out.println("当前账户余额：" + balance);
			balance -= output;
			System.out.println("取款成功");
			System.out.println("取出金额: " + output);
			System.out.println("账户余额为： " + balance);
		} else {
			System.out.println("取款失败！当前账户余额：" + balance);
			System.out.println("至少要保留 " + minBalance + "元");
		}
	}

	/**
	 * 存款
	 */
	private void cunKuan() {
		System.out.println("请输入存款金额：");
		Scanner scanner = new Scanner(System.in);
		double input = scanner.nextDouble();
		System.out.println("存入金额：" + input);
		balance += input;
		System.out.println("当前账户余额：" + balance);
	}
	
	
	
}
